// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 *
 * @author: yanking
 * Create time: 2022-03-31 13:07
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.LeetCodeT.DateTrain;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class SelfDividingNumbers {
    /**
     * 自除数
     */
    public List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> res = new ArrayList<Integer>();
        return IntStream.rangeClosed(left, right).filter(this::filter).boxed().collect(Collectors.toList());

    }

    public boolean filter(int num) {
        int tmp = num;
        while (num > 0) {
            int k = num % 10;
            if (k == 0 || tmp % k != 0) {
                return false;
            }
            num /= 10;
        }
        return true;
    }


    @Test
    public void shout() {
        System.out.println(filter(21));
    }
}
